<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.domain.ZhongLei,java.util.ArrayList,com.domain.*"%>

<%
YongHu yonghu=(YongHu)session.getAttribute("yonghu");

ArrayList<ZhongLei> quanbuzhonglei=(ArrayList<ZhongLei>)session.getAttribute("quanbuzhonglei");
ZhongLei zhonglei;	

ArrayList<ShangPin> shouyeshangpin=(ArrayList<ShangPin>)session.getAttribute("shouyeshangpin");
ShangPin shangpin;

if(yonghu==null)
{
	request.getRequestDispatcher("yonghudenglu.jsp").forward(request, response);

}

if(quanbuzhonglei==null || shouyeshangpin==null)
{
	request.getRequestDispatcher("Shangchengshouye").forward(request, response);
}
%>

<html>
  <head>
	  <style>A{text-decoration: NONE} </style>
	  <title>商城首页</title>
  </head>
  <body bgcolor="#d0eed8">
  	<img src="./images/shangchengshouye.jpg" width="100%"/>	
	<div align="right">
		<a href="Gerenzhongxin"><%=yonghu.getYonghuming()%></a>
		&nbsp;
		<a href="Tuichu">退出</a>	
	</div>

	<form action="Jiazaifenlei" method="post">
		选择分类
		<select name="zhongleibianhao">
 <%
		for(int i=0;i<quanbuzhonglei.size();i++)
		{
			 zhonglei=quanbuzhonglei.get(i);
%>
			<option value=<%=zhonglei.getBianhao() %>><%=zhonglei.getMingzi() %></option>
<%
		}
%>
		</select>
		<input name="submit1" value="确定" type="submit" />			
	</form>

	<table align="center" width="100%" cellspacing="10" >
 <%
	for(int i=0,j=0,k=0,l;i<quanbuzhonglei.size();i++)
	{
		l=j;
		zhonglei=quanbuzhonglei.get(i);
		shangpin=shouyeshangpin.get(j);
		String zhongleibianhao=zhonglei.getBianhao();
		if(zhongleibianhao.equals(shangpin.getBianhao().substring(0,5)))
		{			
%>
			<tr height="50" valign="bottom"><td>>>>>>>>>>><a href="Jiazaifenlei?zhongleibianhao=<%=zhonglei.getBianhao() %>"><%=zhonglei.getMingzi()%></a></td></tr>

			<tr align="center" valign="top">
<% 
			do
			{
%>		
				<th width="20%"  colspan="2"><a href="Shangpinxiangqing?shangpinbianhao=<%=shangpin.getBianhao()%>"><%=shangpin.getMingzi() %></a></th>
<%
				j++;
				if(j==shouyeshangpin.size())
					break;
				shangpin=shouyeshangpin.get(j);				
			}while(zhongleibianhao.equals(shangpin.getBianhao().substring(0,5)));
%>		
			</tr>
		
			<tr align="center">

<% 
			for(;k<j;k++)
			{
				shangpin=shouyeshangpin.get(k);
%>					
				<td  colspan="2">
					<a href="Shangpinxiangqing?shangpinbianhao=<%=shangpin.getBianhao()%>">
						<img src="./images/<%=shangpin.getTupian().get(0) %>.jpg" width="100%">
					</a>
				</td>		
<%
			}
%>			
			</tr>
			
			<tr align="center">
<% 
			for(k=l;k<j;k++)
			{
				shangpin=shouyeshangpin.get(k);
%>						
				<td >¥ <%=shangpin.getJiage() %></td>
				<td >剩余<%=shangpin.getShuliang() %>件</td>			
<%
			}
%>			
			</tr>
			
			<tr  align="center" valign="top">
<% 
			for(k=l;k<j;k++)
			{
				shangpin=shouyeshangpin.get(k);
%>						
				<td  colspan="2">
					<a href="Shangpinxiangqing?shangpinbianhao=<%=shangpin.getBianhao()%>"><%=shangpin.getMiaoshu() %></a>
				</td>		
<%
			}
%>
			</tr>				
<%
		}
	}
%>	
	</table>	
  </body>
</html>
